package com.mianshi.java01.entity;

import java.util.HashMap;
import java.util.Map;

// 顾客类
public class Customer {
    private String name;
    private Map<Fruit, Integer> shoppingCart;

    public Customer(String name) {
        this.name = name;
        this.shoppingCart = new HashMap<>();
    }

    public String getName() {
        return name;
    }

    public void addToCart(Fruit fruit, int quantity) {
        shoppingCart.put(fruit, shoppingCart.getOrDefault(fruit, 0) + quantity);
    }

    public Map<Fruit, Integer> getShoppingCart() {
        return shoppingCart;
    }
}
